package drone.basis.util ;

import java.net.URLEncoder ;

import com.alibaba.fastjson.JSONObject ;

public class MapUtil
{

	// 天地图
	public static String address (
			String url ,
			String postStr ,
			String geocode
	)
	{
		try
		{

			String path = url + "&postStr=" + URLEncoder.encode ( postStr , "UTF-8" ) + "&type=" + geocode ;

			System.out.println ( path ) ;
			
			String result = HttpUtil.get ( path ) ;
			
			System.out.println ( result ) ;

			JSONObject addrJson = JSONObject.parseObject ( result ) ;

			String addr = addrJson.getJSONObject ( "result" ).getString ( "formatted_address" ) ;

			return addr ;

		} catch ( Exception e )
		{
			System.out.println ( "获取指定坐标位置名称异常 : "+e.getMessage ( ) ) ;
			return StringUtil.EMPTY ;
		}
	}
	
	public static void main (
			String [ ] args
	)
	{
		String res=address("http://api.tianditu.gov.cn/geocoder?tk=d1a39d1dd7e46a071cf3ef960f2978cc","{'lon':119.31,'lat':33.11,'ver':1}","geocode" );
		System.out.println ( res ) ;
	}

}
